package com.baofu.paycore.common.enums;

import com.system.commons.exception.BizServiceException;
import com.system.commons.exception.CommonErrorCode;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

/**
 * 标识枚举
 * User: LZQ   Date: 2015/08/10 ProjectName: paycore Version: 1.0
 */
@Slf4j
@Getter
@AllArgsConstructor
public enum FlagEnum {

    /**
     * TRUE     是
     * FALSE    否
     */
    TRUE("TRUE", "是"),
    FALSE("FALSE", "否");

    private final String code;

    private final String value;

    /**
     * 根据Code获取Value
     *
     * @param code 键
     * @return 值
     */
    public static String explain(String code) {
        for (FlagEnum certifyEnum : FlagEnum.values()) {
            if (certifyEnum.getCode().equals(code)) {
                return certifyEnum.getValue();
            }
        }
        log.error("flag 标示不存在:{}",code);
        throw new BizServiceException(CommonErrorCode.PARAMETER_VALID_NOT_PASS);
    }
}
